import request from '@/utils/request'
import axios from "axios";

// 查询每日车次列表
export function listDailyTrain(query) {
  return request({
    url: '/business/daily-train/list',
    method: 'get',
    params: query
  })
}

// 查询每日车次详细
export function getDailyTrain(id) {
  return request({
    url: '/business/daily-train/' + id,
    method: 'get'
  })
}

// 新增每日车次
export function addDailyTrain(data) {
  return request({
    url: '/business/daily-train',
    method: 'post',
    data: data
  })
}

// 修改每日车次
export function updateDailyTrain(data) {
  return request({
    url: '/business/daily-train',
    method: 'put',
    data: data
  })
}

//生成车次
export function genDailyTrain(date) {  // 改为接收 date 参数
  return axios.get( '/api2/business/admin/daily-train/gen-daily/' + date)  // 匹配后端 GET + PathVariable
    .then(res => {
      console.log(res);
      return res;
    });
}

// 删除每日车次
export function delDailyTrain(id) {
  return request({
    url: '/business/daily-train/' + id,
    method: 'delete'
  })
}

// 查询每日车次分组列表
export function listDailyTrainByGroup(query) {
  return request({
    url: '/business/daily-train/listByGroup',
    method: 'get',
    params: query
  })
}